import React, { Component } from 'react'
import { Context } from '../../context'

/* export default class B extends Component {
  render() {
    return (
      <Context.Consumer>{(value) => <div>B {value.age}</div>}</Context.Consumer>
    )
  }
} */

export default class B extends Component {
  // 声明一个静态属性 contextType 等于 Context 对象
  static contextType = Context
  // 然后就可以通过 this.context 拿到传递过来的数据啦
  render() {
    return <div>B {this.context.age}</div>
  }
}
